<!DOCTYPE html>
<html>
<head>
<%include("../../tpl/head.html"){}%>
<title>后台管理-发送消息</title>
</head>
<body class="sidebar-mini fixed skin-blue">
	<div class="wrapper">
		<!-- 头部 -->
		<%include("../../tpl/header.html"){}%>
		<!-- 网页正文 -->
		<div class="content-wrapper">
			<!-- 网页正文-面包屑 -->
			<div class="content-header">
				<h1>发送消息</h1>
				<ol class="breadcrumb">
					<li><a href="/admin/index.jspx"><i class="fa fa-dashboard"></i> 后台系统</a></li>
					<li><a href="#">通知消息</a></li>
					<li class="active">发送消息</li>
				</ol>
			</div>
			<!-- 网页正文-主体 -->
			<section class="content">
				<div class="row">
					<div class="col-md-12">
						<div class="box box-info">
							<div class="box-header with-border">
								<h3 class="box-title"></h3>
							</div>
							<form class="form-horizontal" action="send.json">
								<div class="box-body">
									<div class="form-group">
										<label class="col-lg-2 col-md-3 col-sm-4 control-label">收信人</label>
										<div class="col-lg-6 col-md-7 col-sm-8">
											<select class="form-control select2" multiple name="account" data-placeholder="请选择收信人" data-ajax--url="findUser.json" data-ajax--delay="500" data-cache="true" data-language="zh-CN" style="width: 100%" required></select>
										</div>
									</div>
									<div class="form-group">
										<label class="col-lg-2 col-md-3 col-sm-4 control-label">标题</label>
										<div class="col-lg-6 col-md-7 col-sm-8">
											<input type="text" class="form-control" name="title" placeholder="请输入标题" required>
										</div>
									</div>
									<div class="form-group">
										<label class="col-lg-2 col-md-3 col-sm-4 control-label">消息类型</label>
										<div class="col-lg-6 col-md-7 col-sm-8">
											<select class="form-control" name="type">
												<option value="0">消息类型1</option>
												<option value="1">消息类型2</option>
												<option value="2">消息类型3</option>
											</select>
										</div>
									</div>
									<div class="form-group">
										<label class="col-lg-2 col-md-3 col-sm-4 control-label">发送时间</label>
										<div class="col-lg-6 col-md-7 col-sm-8">
											<input type="text" class="form-control" name="sendTime" readonly placeholder="点击选择发送时间" data-laydate data-format="YYYY/MM/DD" data-istime="false" data-min='${date(),"yyyy/MM/dd"}' required>
										</div>
									</div>
									<div class="form-group">
										<label class="col-lg-2 col-md-3 col-sm-4 control-label">连接地址</label>
										<div class="col-lg-6 col-md-7 col-sm-8">
											<input type="text" class="form-control" name="link" placeholder="请输入连接地址">
										</div>
									</div>
									<div class="form-group">
										<label class="col-lg-2 col-md-3 col-sm-4 control-label">图片</label>
										<div class="col-lg-6 col-md-7 col-sm-8 upload" data-extensions="jpg,png" data-compress="true" id="image-upload">
											<input type="hidden" name="picture" data-value value="">
											<div class="picker">选择图片</div>
											<div id="fileList" class="upload"></div>
										</div>
									</div>
									<div class="form-group">
										<label class="col-lg-2 col-md-3 col-sm-4 control-label">消息主体</label>
										<div class="col-lg-6 col-md-7 col-sm-8">
											<textarea class="form-control" rows="3" name="content" placeholder="请输入消息主体" required></textarea>
										</div>
									</div>
									<div class="form-group">
										<label class="col-lg-2 col-md-3 col-sm-4 control-label">消息附带参数</label>
										<div class="col-lg-6 col-md-7 col-sm-8">
											<input type="text" class="form-control" name="param" placeholder="请输入消息附带参数">
										</div>
									</div>
									<div class="form-group">
										<label class="col-lg-2 col-md-3 col-sm-4 control-label">正文</label>
										<div class="col-lg-6 col-md-7 col-sm-8">
											<textarea class="textarea" placeholder="请输入正文" style="width: 100%; height: 200px; font-size: 14px; line-height: 18px; border: 1px solid #dddddd; padding: 10px;"></textarea>
										</div>
									</div>
								</div>
								<!-- /.box-body -->
								<div class="box-footer">
									<div class="row">
										<div class="col-lg-6 col-md-7 col-sm-8 col-lg-offset-2 col-md-offset-3 col-sm-offset-4">
											<button type="button" class="btn btn-default">取消</button>
											<button type="submit" class="btn btn-info pull-right">发送</button>
										</div>
									</div>
								</div>
								<!-- /.box-footer -->
							</form>
						</div>
					</div>
				</div>
			</section>
			<!-- /.content -->
		</div>
		<!-- 网页底部 -->
		<%include("../../tpl/footer.html"){}%>
	</div>
	<%include("../../tpl/script.html"){}%>
	<script type="text/javascript">
		$(document).ready(function() {
			$("form").on('submit-success', function(e, result) {
				this.reset();
				layer.msg("发送成功", {
					icon : 1,
					time : 1500
				});
			}).validate();
			$(".select2").select2();
			$(".textarea").wysihtml5({
				locale : 'zh-CN',
				toolbar : {
					custom1 : true,
					html : true,
					size : 'sm',
				},
				customTemplates : {
					custom1 : function() {
						return '<li><a class="btn btn-default btn-sm" data-wysihtml5-command="insertHTML" data-wysihtml5-command-value="&hellip;">hellip</a></li>';
					}
				}
			});
			// 图片上传成功事件
			$('#image-upload').on('uploadSuccess', function(e, file, result) {
				$('.upload #fileList').html('<img class="img-thumbnail" src="'+result.data+'" style="width:200px;height:100px;">');
			})

			// 封装好的webuploader控件初始化
			$('.upload').each(function() {
				var $this = $(this);
				var opt = {
					auto : true,
					swf : '/assets/plugins/webuploader/Uploader.swf',
					server : '/api/upload.json',
					pick : $this.find('.picker'),
					resize : false
				};
				if ($this.data('extensions')) {
					opt.accept = {
						title : 'upload-accept',
						extensions : $this.data('extensions')
					}
				}
				if ($this.data('compress')) {
					opt.compress = {
						width : 1600,
						height : 1600,
						quality : 90,
						allowMagnify : false,
						crop : false,
						preserveHeaders : true,
						noCompressIfLarger : false,
						compressSize : 1 * 1024 * 1024
					}
				}
				$this.data('_uploader', WebUploader.create(opt));
				$this.data('_uploader').on('uploadProgress', function(file, progress) {
					$this.find('span').remove();
					$this.append('<span>正在上传:' + parseInt(progress * 100) + '%</span>');
				});
				$this.data('_uploader').on('uploadSuccess', function(file, response) {
					$this.find('input[data-value]').val(response.data);
					$this.find('span').remove();
					$this.append('<span>上传成功</span>');
					$this.trigger('uploadSuccess', [ file, response ]);
				});
			});

		});
	</script>
</body>
</html>
